﻿using System;
using System.Data;
using System.Collections.Generic;
using DataLib.Common;
using DataLib.Model;
namespace DataLib.BLL
{
	/// <summary>
	/// Tally
	/// </summary>
	public partial class Tally
	{
		#region  ExtensionMethod
              /// <summary>
        /// 提交事件，所有的理货数据状态更新为1，为正式数据
        /// </summary>
        /// <param name="id">物料理货的id</param>
        /// <returns></returns>
        public bool BupdateStatus(int? id)
        {
            return dal.BupdateStatus(id);
        }

               /// <summary>
        /// 获取原料理货数据
        /// </summary>
        /// <returns></returns>
        public DataTable GetTallyItem(string loadnum,
                            string cum,
                            string dtime1,
                            string dtime2,
                            string b_goodscode,
                            string b_boxid,
                            string b_ldh,
                            string classtype,
                            string a_goodscode,
                            string a_boxid,
                            string a_ldh
                            )
        {
            return dal.GetTallyItem(loadnum, cum, dtime1, dtime2, b_goodscode, b_boxid, b_ldh, classtype, a_goodscode, a_boxid, a_ldh);
        }


        public DataTable GetTallyProc(string LoadNo, string CustomName, string CjoNo,
           string Wrlno, string classify, string conduct, string beginDate, string endDate, string belong, string graphic)
        {
            if (endDate != "")
            {
                DateTime ed = Convert.ToDateTime(endDate);
                endDate = ed.AddDays(1).AddSeconds(-1).ToString();
            }
            return dal.GetTallyProc(LoadNo, CustomName, CjoNo, Wrlno, classify, conduct, beginDate, endDate,belong,graphic);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="city"></param>
        /// <returns></returns>
        public DataTable GetTallyList(string city,string cumid)
        {
            return dal.GetTallyList(city,cumid);

        }

        
        /// <summary>
        /// 根据Load单查一单原料理货信息
        /// </summary>
        /// <param name="guilei">归类</param>
        /// <param name="loadid">Load单的ID</param>
        /// <returns></returns>
        public DataTable GetTallyDetail(string guilei, int loadid)
        {
            return dal.GetTallyDetail(guilei, loadid);
        }

        
        /// <summary>
        /// 根据Load单查一单原料理货信息
        /// </summary>
        /// <param name="guilei">归类</param>
        /// <param name="loadid">理货ID</param>
        /// <returns></returns>
        public DataTable GetTallyDetailByid(string guilei, int tallyid)
        {
            return dal.GetTallyDetailByid(guilei, tallyid);
        }

           /// <summary>
        /// 根据Loadid取到理货ID，如果没有理货返回0
        /// </summary>
        /// <param name="loadid"></param>
        /// <returns></returns>
        public int GetTallyID(int loadid)
        {
            return dal.GetTallyID(loadid);
        }


        /// <summary>
        /// 根据LoadID取得分类入库单的ID，如果没有则返回0
        /// </summary>
        /// <param name="loadid"></param>
        /// <returns></returns>
        public Model.InStorage GetInsID(int loadid)
        {
            return dal.GetInsID(loadid);
        }

        /// <summary>
        /// 根据loadＩＤ获取对应的Model
        /// </summary>
        /// <param name="loadid"></param>
        /// <returns></returns>
        public Model.Tally GetModelByloadid(int loadid)
        {
            Model.Tally model = new Model.Tally();
            DataTable dt = GetList("loadid=" + loadid.ToString()).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                model = dal.DataRowToModel(dt.Rows[0]);
            }
            else
            {
                model = null;
            }
            return model;
        }

        
        /// <summary>
        /// 提交事件，所有的理货数据状态更新为1，为正式数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool BupdateStatus(Model.Tally model)
        {
            return dal.BupdateStatus(model);
        }


        /// <summary>
        /// 根据Ｌｏａｄ取得所有原料处理后数据
        /// </summary>
        /// <param name="loadno"></param>
        /// <returns></returns>
        public DataTable GetBarList_F(string loadno)
        {
            return dal.GetBarList_F(loadno);
        }

        
        /// <summary>
        /// 根据Ｌｏａｄ取得所有原料处理后数据
        /// </summary>
        /// <param name="loadno"></param>
        /// <returns></returns>
        public DataTable GetUnList_F(string loadno)
        {
            return dal.GetUnList_F(loadno);
        }

        
        /// <summary>
        /// 某一Load下的理货列表
        /// </summary>
        /// <param name="loadno"></param>
        /// <returns></returns>
        public DataTable GetTallyList(int loadid, int outid)
        {
            return dal.GetTallyList(loadid, outid);
        }

        /// <summary>
        /// 取最新原料理货编号
        /// <param name="delnoid">如果是从删除中取号就传回删除表的ID</param>
        /// </summary>
        /// <returns></returns>
        public string GetMaxTallyNo(out int delnoid)
        {
            return dal.GetMaxTallyNo(out delnoid);
        }

                /// <summary>
        /// 获取Load的称重收集日期
        /// </summary>
        /// <param name="loadid"></param>
        /// <returns></returns>
        public string getCollDate(int loadid)
        {
            return dal.getCollDate(loadid);
        }

              /// <summary>
        /// 获取Load的分类入库日期
        /// </summary>
        /// <param name="loadid"></param>
        /// <returns></returns>
        public string getInsDate(int loadid)
        {
            return dal.getInsDate(loadid);
        }

               /// <summary>
        /// 判断分类入库是否完成
        /// </summary>
        /// <param name="loadid"></param>
        public string GetClassifyStatus(string loadnum)
        {
            return dal.GetClassifyStatus(loadnum);
        }

        
        /// <summary>
        /// 根据移库ID取得所有原料处理前数据
        /// </summary>
        /// <param name="loadno"></param>
        /// <returns></returns>
        public DataTable GetUnList_Outs_F(int outid)
        {
            return dal.GetUnList_Outs_F(outid);
        }

               /// <summary>
        /// 根据移库ID取得所有原料处理后数据
        /// </summary>
        /// <param name="loadno"></param>
        /// <returns></returns>
        public DataTable GetBarList_Outs_F(int outid)
        {
            return dal.GetBarList_Outs_F(outid);
        }

               /// <summary>
        /// 根据移库ID及字段名，取得对应值
        /// </summary>
        /// <param name="outid"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public string GetOutsInfo(int outid, string filename)
        {
            return dal.GetOutsInfo(outid, filename);
        }

                /// <summary>
        /// 获取移库称重分类日期
        /// </summary>
        /// <param name="loadid"></param>
        /// <returns></returns>
        public string getOutsInsDate(string vload)
        {
            return dal.getOutsInsDate(vload);
        }

               /// <summary>
        /// 获取移库称重收集日期
        /// </summary>
        /// <param name="loadid"></param>
        /// <returns></returns>
        public string getOutCollDate(int outid)
        {
            return dal.getOutCollDate(outid);
        }

              /// <summary>
        /// 获取原料理货剩余重量
        /// </summary>
        /// <returns></returns>
        public decimal GetTallyWeight(int dataid, int nwttype)
        {
            return dal.GetTallyWeight(dataid, nwttype);
        }

        public DataTable GetTallyListByStore(string city, string cumid, int currpage, int length, out int totalRecord,
                                             string search)
        {
            return dal.GetTallyListByStore(city, cumid, currpage, length, out totalRecord, search);
        }

    
     /// <summary>
        /// 根据Tally获取Load的收集日期
        /// </summary>
        /// <param name="loadid"></param>
        /// <returns></returns>
        public string getWrlDate(int id, string type, string c)
        {
            return dal.getWrlDate(id,type,c);
        }

		#endregion  ExtensionMethod
	}
}

